package com.game.worm.mobile.view.home.adpater;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.dx.as.image.ImageLoaderKit;
import com.dx.as.ui.adpater.RecyclerAdapter;
import com.game.worm.mobile.R;
import com.game.worm.mobile.bean.GameBean;
import com.game.worm.mobile.view.GameHelper;
import com.nostra13.universalimageloader.core.ImageLoader;

import org.w3c.dom.Text;

/**
 * Created by d_xxiang on 2018/3/28.
 */

public class GamedAdpater extends RecyclerAdapter<GameBean,GamedAdpater.ViewHolder> {

    public GamedAdpater(Context context) {
        super(context);
    }

    @Override
    public GamedAdpater.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_home_game_list, parent, false);
        return new GamedAdpater.ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(GamedAdpater.ViewHolder holder, int position) {
        GameBean gameBean = data.get(position);
        holder.itemView.setOnClickListener(GameHelper.getOnItemClickListener(gameBean.getId()));
        ImageLoader.getInstance().displayImage(gameBean.getImgUrlIcon(),holder.ico);
        holder.name.setText(gameBean.getName());
        holder.score.setText(gameBean.getGameScore());
    }


    public static class ViewHolder extends RecyclerView.ViewHolder{

        public ImageView ico;
        public TextView name;
        public TextView integral;
        public TextView score;
        public TextView lb;
        public ViewHolder(View itemView) {
            super(itemView);
            ico = itemView.findViewById(R.id.ico);
            name = itemView.findViewById(R.id.name);
            integral = itemView.findViewById(R.id.integral);
            score = itemView.findViewById(R.id.score);
            lb = itemView.findViewById(R.id.lb);
        }
    }

}
